<template>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm" >
  <el-form-item label="司机id" > 
    <el-input v-model="ruleForm.driverId" placeholder="请输入已有司机id"></el-input>
  </el-form-item>
  <el-form-item label="发起人工号" >
    <el-input v-model="ruleForm.applyUserId" placeholder="请输入有效职工工号"></el-input>
  </el-form-item>
  <el-form-item label="出发地点" >
    <el-input v-model="ruleForm.setoffAddress"></el-input>
  </el-form-item>
  <el-form-item label="到达地点" >
    <el-input v-model="ruleForm.arrivalAddress"></el-input>
  </el-form-item>
  <el-form-item label="乘车人数" >
    <el-input v-model="ruleForm.passengersNum"></el-input>
  </el-form-item>
  <el-form-item label="里程数" >
    <el-input v-model="ruleForm.totalKM"></el-input>
  </el-form-item>
  <el-form-item label="出发时间" required>
    <el-col :span="11">
      <el-form-item prop="setoffTime">
        <el-date-picker type="date" placeholder="选择日期" v-model="ruleForm.setoffTime" style="width: 100%;"></el-date-picker>
      </el-form-item>
    </el-col>
    <el-col class="line" :span="2">-</el-col>
    <el-col :span="11">
      <el-form-item prop="setoffTime">
        <el-time-picker placeholder="选择时间" v-model="ruleForm.setoffTime" style="width: 100%;"></el-time-picker>
      </el-form-item>
    </el-col>
  </el-form-item> 
  <el-form-item>
    <el-button type="primary" @click="submint()">提交</el-button>
    <el-button >重置</el-button>
  </el-form-item>
</el-form>
</template>
<script>

import request from '../api/request.js'
import { checkLoginStatusApi } from '../api/user.js';
  export default {
    inject: ['reload'],
    data() {
      return {
        ruleForm: {
          driverId: '',
          applyUserId: '',
          setoffAddress: '',
          setoffTime: '',
          arrivalAddress: '',
          passengersNum: '',
          totalKM:''
        },
        rules: {
          driverId: [
            { required: true, message: '请输入司机id', trigger: 'blur' },
          ],
          applyUserId: [
            { required: true, message: '请输入发起人工号', trigger: 'change' }
          ],
          setoffTime: [
            { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
          ],
          setoffTime: [
            { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
          ],
          arrivalAddress: [
            { required: true, message: '请输入达到地点', trigger: 'change' }
          ],
          passengersNum: [
            { required: true, message: '请输入乘车人数', trigger: 'blur' }
          ],
          totalKM: [
            { required: true, message: '请输入里程数', trigger: 'blur' }
          ]
        }
      };
    },
    methods: {
      submint(){
         console.log(this.ruleForm)
        request({
        url: '/order/creatOrder',
        method: 'post',
        data: {
          order:this.ruleForm
          }
    }).then(res=>{
            this.$confirm('创建订单成功')
            this.reload()
        }).catch(res => {
          console.log(err)
        })
      }
    }
  }
</script>